<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 4，打印100-999之间的水仙花数（153==1^3+5^3+3^3） -->
    <script>
      
            for (var i = 100; i <= 999; i++) {
            var a = i % 10;
            var b = parseInt(i % 100 / 10);
            var c = parseInt(i / 100);

          var n=Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3)
           if(n==i){
            console.log(i);
           }
            
        }
 
    
       
    </script> 
    <!-- <script>
        var arr = []
        var count = 0;
        for (var i = 1; i < 10; i++) {
            for (var j = 0; j < 10; j++) {
                for (var k = 1; k < 10; k++) {
                    var n1 = 100 * i + j * 10 + k;
                    var n2 = Math.pow(i, 3) + Math.pow(j, 3) + Math.pow(k, 3);
                    if(n1==n2){
                        count++;
                        arr.push(n1)
                    }
                }
            }
        }
        console.log("水仙花数是"+arr);
        
    </script> -->
</body>

</html>